package org.study.common.model;

import com.alibaba.fastjson.JSON;
import lombok.Data;

import java.util.List;

public class ResultUtils {
    @Data
    public static class Result<E>{
        public String message;

        public String status;

        public String code;

        public E data;

        public List<E> list;

        public Result setMessage(String msg){
            this.message = msg;
            return this;
        }

        public Result setStatus(String status){
            this.status = status;
            return  this;
        }
        public Result setCode(String code){
            this.code = code;
            return this;
        }

        public Result setData(E data){
            this.data = data;
            return this;
        }

        public Result setList(List<E> list){
            this.list = list;
            return this;
        }
    }

    public static String returnSuccessMsg(String msg){
        return JSON.toJSONString(new Result<String>().setMessage(msg).setStatus("200"));
    }
}
